package com.suray.commin.exception;

import com.suray.commin.core.utils.StringUtils;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = false)
public class OrderExecuteException extends RuntimeException {
    /**
     *
     */
    private static final long serialVersionUID = 1L;
    /**
     * 设备编号
     */
    private int deviceNo;
    /**
     * 故障码
     */
    private int code;
    /**
     * 详细信息
     */
    private String message;

    public OrderExecuteException(int deviceNo, int code, String message) {
        this.deviceNo = deviceNo;
        this.code = code;
        this.message = "设备编号:" + deviceNo + ",异常码:" + code + ",原因:" + message;
    }

    public OrderExecuteException(int deviceNo, int code) {
        this.deviceNo = deviceNo;
        this.code = code;
    }

    public String getErrorMessage() {
        if (StringUtils.isEmpty(message)) {
            return "设备编号:" + deviceNo + ",异常码:" + code;
        } else {
            return message;
        }
    }
}
